package com.example.easybuy.config;

import com.example.easybuy.interceptor.UserCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyMvcConfig implements WebMvcConfigurer {
    private UserCheckInterceptor userCheckInterceptor;
    @Autowired
    public MyMvcConfig(UserCheckInterceptor userCheckInterceptor) {
        this.userCheckInterceptor = userCheckInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userCheckInterceptor)
                .addPathPatterns("/news/addNews")
                .addPathPatterns("/news/delNews")
                .addPathPatterns("/news/updateNews")
                .addPathPatterns("/order/**")
                .addPathPatterns("/product/doAdd")
                .addPathPatterns("/product/doUpdate")
                .addPathPatterns("/product/doDel")
                .addPathPatterns("/type/addType")
                .addPathPatterns("/type/updateType")
                .addPathPatterns("/type/delType")
                .addPathPatterns("/user/delUser")
                .addPathPatterns("/user/exit")
                .addPathPatterns("/user/updateUser");
    }
}